<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title></title>
    <link rel="stylesheet" href="admin/css/login.css" />
    <link rel="stylesheet" href="component/layui/css/layui.css" />
</head>
<body background="admin/images/background.svg">
<form class="layui-form" action="javascript:void(0);">
    <div class="layui-form-item">
        <img class="logo" src="admin/images/logo.png" />
        <div class="title">Pear Admin</div>
        <div class="desc">
             明 湖 区 最 具 影 响 力 的 设 计 规 范
        </div>
    </div>
    <div class="layui-form-item">
        <input name="username" type="text" placeholder="账 户 : " value="admin" hover class="layui-input" />
    </div>
    <div class="layui-form-item">
        <input name="password" type="password" placeholder="密 码 : " value="admin" hover class="layui-input" />
    </div>
    <div class="layui-form-item">
        <input type="checkbox" name="" title="记住密码" lay-skin="primary" checked>
    </div>
    <div class="layui-form-item">
        <button class="pear-btn pear-btn-primary" lay-submit="" lay-filter="login">
            登 入
        </button>
    </div>
</form>
<script src="component/layui/layui.js"></script>
<script>
    layui.use(['form','jquery','layer'], function() {
        let form = layui.form;
        let $ = layui.jquery;
        let layer = layui.layer;

        //监听提交
        form.on('submit(login)', function(data){
            let loader = layer.load();
            $.ajax({
                url:'/login',
                data:data.field,
                type:"post",
                dataType:'json',
                success:function(result){
                    layer.close(loader);
                    if(result.success){
                        layer.msg(result.msg,{icon:1,time:1000},function(){
                            location.href = "/index";
                        })
                    }else{
                        layer.msg(result.msg,{icon:2,time:1000});
                    }
                }
            });
            return false;
        });
    })
</script>
</body>
</html>
